#include "FileBackupThread.h"
#include <QFile>

// 构造函数实现
FileBackupThread::FileBackupThread(const QString& sourcePath, const QString& destPath, QObject* parent)
    : QThread(parent), sourcePath_(sourcePath), destPath_(destPath) {}

// run() 函数实现
void FileBackupThread::run() {
    QFile::remove(destPath_); // 先尝试删除目标文件，以防已经存在且内容不同
    if (QFile::copy(sourcePath_, destPath_)) {
        emit backupSuccess(sourcePath_, destPath_);
    } else {
        emit backupFailed(sourcePath_, destPath_);
    }
}


